<template>
  <div class="test">
    <VTable
      :tableData="tableData.data"
      :tableHeader="tableHeader"
      :tableHandle="''"
      :tableHandle1="''"
      :tableHandle2="''"
      :tableSort="tableSort"
      v-loading="listLoading">
    </VTable>
  </div>
</template>
<script>
  import VTable from '../../components/VTable.vue'
  var moment = require('moment')
  import {mapState, mapGetters} from 'vuex'
  import * as types from '../../store/mutations-type'
  export default {
    data () {
      return {
        currentPage: 1,
        limit: 20,
        listLoading: false,
        tableHeader: [
          {prop: 'accountName', label: '审核账号', width: 140},
          {prop: 'preStatus', label: '审核前状态', width: 140, formatter: this.formatterPre},
          {prop: 'postStatus', label: '审核后状态', width: 140, formatter: this.formatterPost},
          {prop: 'logContent', label: '审核内容'},
          {prop: 'logRemark', label: '审核备注'},
          {prop: 'createTime', label: '创建时间', formatter: this.formatterCreatetime}
        ]
      }
    },
    components: {
      VTable
    },
    props: ['balanceId'],
    methods: {
      /**
       * 时间格式化
       * @param row
       * @returns {string}
       */
      formatterCreatetime (row) {
        return moment(new Date(row.createTime)).format('YYYY-MM-DD hh:mm:ss')
      },
      /**
       * 订单状态转义
       * @param row
       * @returns {string}
       */
      formatterPre (row) {
        return row.preStatus === '1' ? '待业务审核' : row.preStatus === '2' ? '待财务审核' : row.preStatus === '3' ? '审核通过' : row.preStatus === '4' ? '已结算' : row.preStatus === '5' ? '废除结算单' : ''
      },
      formatterPost (row) {
        return row.postStatus === '1' ? '待业务审核' : row.postStatus === '2' ? '待财务审核' : row.postStatus === '3' ? '审核通过' : row.postStatus === '4' ? '已结算' : row.postStatus === '5' ? '废除结算单' : ''
      },
      /**
       * 每页条数
       * @param val
       */
      handleSizeChange (val) {
        console.log(`每页 ${val} 条`)
      },
      /**
       * 翻页
       * @param val
       */
      handleCurrentChange (val) {
        this.currentPage = val
        this.getTableData()
      },
      getTableData () {
        this.$store.dispatch(types.LOGGER_REQ_LIST, '?balanceId=' + this.balanceId)
      },
      /**
       * 列表排序
       * @param column
       * @param prop
       * @param order
       */
      tableSort (column, prop, order) {
      }
    },
    computed: {
      ...mapState({
        dialogVisible: state => state.logger.dialogVisible,
        checkNum: state => state.logger.checkNum
      }),
      ...mapGetters({
        tableData: 'logger_tableData'
      })
    },
    mounted () {
      this.getTableData()
    }
  }
</script>
<style>
  .test {
    width: 1000px;
  }
</style>
